package com.su.song.myactiviy;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.su.song.myactiviy.Util.DataUtil;

public class ReceiveActivity extends AppCompatActivity {

    private TextView tv_receive;
    private static final String mresponse = "已摸，+9";
    private TextView tv_reply;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_receive);
        tv_receive = findViewById(R.id.tv_receive);
        tv_reply = findViewById(R.id.tv_reply);
        Bundle bundle = getIntent().getExtras();//获取意图里封装的盒子信息
        String request_time = bundle.getString("Request_time");
        String request_text = bundle.getString("Request_text");
        String desc = String.format("获取消息:\n接受信息时间为：%s\n接受信息内容为：%s",request_time,request_text);
        tv_receive.setText(desc);
        tv_reply.setText("待发送的消息：" + mresponse);

        Button btn_receive =  findViewById(R.id.btn_receive);
        btn_receive.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ReceiveActivity.this,SendActivity.class);
                Bundle bumdle2 = new Bundle();
                bumdle2.putString("reply_time",DataUtil.getNowTime());
                bumdle2.putString("reply_text",mresponse);
                intent.putExtras(bumdle2);
                setResult(Activity.RESULT_OK,intent);
                finish();


            }
        });
    }
}